/**
 * 
 */
package com.newtribe.security.kmc;

import java.io.FileInputStream;
import java.io.InputStream;
import java.security.*;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;

/**
 * @author newtribe
 *
 */
public class KeyManager {


	
		public PrivateKey getPrivateKeys() throws Exception {
		   	  
		  	   KeyStore keystore = KeyStore.getInstance("jks");
		  	    InputStream in = new FileInputStream("E:/TEMP/ca/p10test/test.jks");
		  	    keystore.load(in, "123456".toCharArray());
		  	  
		        return  (PrivateKey)keystore.getKey("root", "123456".toCharArray());
		}
		public PublicKey getPublicKeys() throws Exception {
			
		      KeyPairGenerator keyPairGen=KeyPairGenerator.getInstance("RSA");
		      keyPairGen.initialize(1024);
		      KeyPair keyPair=keyPairGen.genKeyPair();

		      PublicKey pubKey=keyPair.getPublic();
		      PrivateKey priKey=keyPair.getPrivate();
		      
		      return pubKey;
			
		}
		
		public 	 X509Certificate getCertificate() throws Exception {
		     X509Certificate cert = null;
		     
		     return cert ;
	
		}


}
